@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">
        <button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>
        <div class="search_box">
            <form id="search_form" method="GET">
                
                <label>
                类型：<br>
                    <select name="type" class="form-control search_form_control">
                        <option value="">全部</option>

                        <option value="0" @if(isset($_search['type']) && $_search['type']===0) selected="" @endif>文章</option>
                        <option value="1" @if(isset($_search['type']) && $_search['type']==1) selected="" @endif>视频</option>
          
                    </select>
                </label>
                <label>
                日期：<br>
                    <input id="ymd" type="text" name="ymd" class="form-control search_form_control" value="{{$_search['ymd']}}">
                </label>
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>
        </div>

        <div class="table-responsive">
            <table class="table">
                <caption>上线数量({{$sum}})</caption>
                <thead>
                    <tr>
                        <th>#</th>
                        <th>类型</th>
                        <th>分类</th>
                        <th>上线数</th>
                        <th>日期</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr id="tr_{{$item->id}}">
                            <td>{{ $item->id }}</td>
                            <td>{{ $item->type==1?'视频':'文章' }}</td>
                            <td>
                                @if($item->type==0)
                                {{ $cats[$item->cat_id]->name??'unfind' }}   [{{$item->cat_id}}]</td>
                                @else
                                {{ $video_cats[$item->cat_id]->name??'unfind' }}   [{{$item->cat_id}}]</td>
                                @endif
                            <td>{{ $item->total }}</td>
                            <td>{{ date('Y-m-d',strtotime($item->ymd)) }}</td>
                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="5">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
                {{ $list->links() }}
            </div>
        </div>

    </div>
@endsection

@section('foot')
<script type="text/javascript">
$.ajaxSetup({
    headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
})

function ajax_delete_theme(id){
    if(confirm('确认删除吗?')){
        $.post("/theme/ajax_delete_theme/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
function set_cat(id,obj){
    var type = $(obj).val();
    var name = $(obj).find("option:selected").text();
    $("td#cat_"+id).text(name);
    $.post('/article/ajax_set_cat/'+id,{type:type},function(json){
    
    },"json");
}

$('#ymd').datepicker({
   language: "zh-CN",
          todayHighlight: true,
          format: 'yyyymmdd',
          autoclose: true,

});
</script>
@endsection